package logic

import (
	"context"
	"manage/models/mysql"

	"manage/managerpc/internal/svc"
	"manage/managerpc/managerpc"

	"github.com/zeromicro/go-zero/core/logx"
)

type RateShowLogic struct {
	ctx    context.Context
	svcCtx *svc.ServiceContext
	logx.Logger
}

func NewRateShowLogic(ctx context.Context, svcCtx *svc.ServiceContext) *RateShowLogic {
	return &RateShowLogic{
		ctx:    ctx,
		svcCtx: svcCtx,
		Logger: logx.WithContext(ctx),
	}
}

func (l *RateShowLogic) RateShow(in *managerpc.RateShowRequest) (*managerpc.RateShowResponse, error) {
	// todo: add your logic here and delete this line

	var rate mysql.Rate
	mysql.DB.Debug().Where("id =?", in.RateId).Find(&rate)
	return &managerpc.RateShowResponse{
		RateId:  rate.RateId,
		UserId:  rate.UserId,
		Context: rate.Context,
	}, nil
}
